import hashlib
import itsdangerous



def encrypt(raw):
    sha256 = hashlib.sha256()
    sha256.update(raw.encode('utf-8'))
    return sha256.hexdigest()


SECRET_KEY = '123456'


def jwt_token(user):
    jwt_ = itsdangerous.TimedJSONWebSignatureSerializer(SECRET_KEY, 300)
    data = {
        'id': user.id
    }
    token = jwt_.dumps(data).decode()
    return token
